package com.xiahui.day03;

import java.util.Scanner;

/**
 * 任务：使用for循环输入某同学的5门成绩  计算平均分
 */
public class TestFor2 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        System.out.println("请输入名字");

        String name = input.next();

        System.out.println("姓名： " + name);

        double sum = 0;//用于累计所有成绩

        for (int i = 1; i <= 5; i++) {
            System.out.println("第" + i + "门成绩");
            double score = input.nextDouble();

            sum = sum + score;//sum+=score
        }
        System.out.println(name + "同学的平均分为：" + sum / 5);

        System.out.println("程序结束");
    }
}
